<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Oboe: oboe::StabilizedCallback Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Oboe
   &#160;<span id="projectnumber">1.2</span>
   </div>
   <div id="projectbrief">A library for creating real-time audio apps on Android</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceoboe.html">oboe</a></li><li class="navelem"><a class="el" href="classoboe_1_1_stabilized_callback.html">StabilizedCallback</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classoboe_1_1_stabilized_callback-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">oboe::StabilizedCallback Class Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="dynheader">
Inheritance diagram for oboe::StabilizedCallback:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classoboe_1_1_stabilized_callback.png" usemap="#oboe::StabilizedCallback_map" alt=""/>
  <map id="oboe::StabilizedCallback_map" name="oboe::StabilizedCallback_map">
<area href="classoboe_1_1_audio_stream_callback.html" alt="oboe::AudioStreamCallback" shape="rect" coords="0,0,167,24"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a2db099d5fcac6fb939f40be16a3abeae"><td class="memItemLeft" align="right" valign="top"><a id="a2db099d5fcac6fb939f40be16a3abeae"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>StabilizedCallback</b> (<a class="el" href="classoboe_1_1_audio_stream_callback.html">AudioStreamCallback</a> *callback)</td></tr>
<tr class="separator:a2db099d5fcac6fb939f40be16a3abeae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad447e12ebf732cf151655c1fbaf58a49"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceoboe.html#af85fc9910a287df6c5df0ed396bb75cd">DataCallbackResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_stabilized_callback.html#ad447e12ebf732cf151655c1fbaf58a49">onAudioReady</a> (<a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *oboeStream, void *audioData, int32_t numFrames) override</td></tr>
<tr class="separator:ad447e12ebf732cf151655c1fbaf58a49"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7ec0e9fca3181962ab78716bcda83e10"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_stabilized_callback.html#a7ec0e9fca3181962ab78716bcda83e10">onErrorBeforeClose</a> (<a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *oboeStream, <a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a> error) override</td></tr>
<tr class="separator:a7ec0e9fca3181962ab78716bcda83e10"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af7521da42c4b08a71e6102994f6f41f4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_stabilized_callback.html#af7521da42c4b08a71e6102994f6f41f4">onErrorAfterClose</a> (<a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *oboeStream, <a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a> error) override</td></tr>
<tr class="separator:af7521da42c4b08a71e6102994f6f41f4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ad447e12ebf732cf151655c1fbaf58a49"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad447e12ebf732cf151655c1fbaf58a49">&#9670;&nbsp;</a></span>onAudioReady()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespaceoboe.html#af85fc9910a287df6c5df0ed396bb75cd">DataCallbackResult</a> oboe::StabilizedCallback::onAudioReady </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *&#160;</td>
          <td class="paramname"><em>oboeStream</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>audioData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>numFrames</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>A buffer is ready for processing.</p>
<p>For an output stream, this function should render and write numFrames of data in the stream's current data format to the audioData buffer.</p>
<p>For an input stream, this function should read and process numFrames of data from the audioData buffer.</p>
<p>The audio data is passed through the buffer. So do NOT call read() or write() on the stream that is making the callback.</p>
<p>Note that numFrames can vary unless <a class="el" href="classoboe_1_1_audio_stream_builder.html#a3f397821f61eabaeedaf31064c859a54">AudioStreamBuilder::setFramesPerCallback()</a> is called.</p>
<p>Also note that this callback function should be considered a "real-time" function. It must not do anything that could cause an unbounded delay because that can cause the audio to glitch or pop.</p>
<p>These are things the function should NOT do: </p><ul>
<li>
allocate memory using, for example, malloc() or new </li>
<li>
any file operations such as opening, closing, reading or writing </li>
<li>
any network operations such as streaming </li>
<li>
use any mutexes or other synchronization primitives </li>
<li>
sleep </li>
<li>
oboeStream-&gt;stop(), pause(), flush() or close() </li>
<li>
oboeStream-&gt;read() </li>
<li>
oboeStream-&gt;write() </li>
</ul>
<p>The following are OK to call from the data callback: </p><ul>
<li>
oboeStream-&gt;get*() </li>
<li>
<a class="el" href="namespaceoboe.html#af65aaea3c5d82eee6906664d61c094b3">oboe::convertToText()</a> </li>
<li>
oboeStream-&gt;setBufferSizeInFrames() </li>
</ul>
<p>If you need to move data, eg. MIDI commands, in or out of the callback function then we recommend the use of non-blocking techniques such as an atomic FIFO.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">oboeStream</td><td>pointer to the associated stream </td></tr>
    <tr><td class="paramname">audioData</td><td>buffer containing input data or a place to put output data </td></tr>
    <tr><td class="paramname">numFrames</td><td>number of frames to be processed </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>DataCallbackResult::Continue or DataCallbackResult::Stop </dd></dl>

<p>Implements <a class="el" href="classoboe_1_1_audio_stream_callback.html#af3a7c44f0254abe6e5e5bb566e2317df">oboe::AudioStreamCallback</a>.</p>

</div>
</div>
<a id="af7521da42c4b08a71e6102994f6f41f4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af7521da42c4b08a71e6102994f6f41f4">&#9670;&nbsp;</a></span>onErrorAfterClose()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void oboe::StabilizedCallback::onErrorAfterClose </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *&#160;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a>&#160;</td>
          <td class="paramname">&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This will be called when an error occurs on a stream or when the stream is disconnected. The underlying AAudio or OpenSL ES stream will already be stopped AND closed by Oboe. So the underlying stream cannot be referenced. But you can still query most parameters.</p>
<p>This callback could be used to reopen a new stream on another device. You can safely delete the old <a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> in this method.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">oboeStream</td><td>pointer to the associated stream </td></tr>
    <tr><td class="paramname">error</td><td></td></tr>
  </table>
  </dd>
</dl>

<p>Reimplemented from <a class="el" href="classoboe_1_1_audio_stream_callback.html#a57a1b21efc764e8bbf8d92008a993bfd">oboe::AudioStreamCallback</a>.</p>

</div>
</div>
<a id="a7ec0e9fca3181962ab78716bcda83e10"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7ec0e9fca3181962ab78716bcda83e10">&#9670;&nbsp;</a></span>onErrorBeforeClose()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void oboe::StabilizedCallback::onErrorBeforeClose </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *&#160;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a>&#160;</td>
          <td class="paramname">&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>This will be called when an error occurs on a stream or when the stream is disconnected.</p>
<p>Note that this will be called on a different thread than the <a class="el" href="classoboe_1_1_stabilized_callback.html#ad447e12ebf732cf151655c1fbaf58a49">onAudioReady()</a> thread. This thread will be created by Oboe.</p>
<p>The underlying stream will already be stopped by Oboe but not yet closed. So the stream can be queried.</p>
<p>Do not close or delete the stream in this method because it will be closed after this method returns.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">oboeStream</td><td>pointer to the associated stream </td></tr>
    <tr><td class="paramname">error</td><td></td></tr>
  </table>
  </dd>
</dl>

<p>Reimplemented from <a class="el" href="classoboe_1_1_audio_stream_callback.html#a77ceb641f941164d7b4d4c51c9a888b9">oboe::AudioStreamCallback</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/oboe/<a class="el" href="_stabilized_callback_8h_source.html">StabilizedCallback.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
